package com.wxzz.elearing.pay.api.admin;


import com.alibaba.fastjson.JSONObject;
import com.wxzz.elearing.pay.dto.CheckUserWithdrawDepositDto;
import com.wxzz.elearing.pay.dto.SendUserWithdrawDepositDto;
import com.wxzz.elearing.pay.dto.UserWithdrawDepositDto;
import com.wxzz.elearing.pay.entity.UserBankCard;
import com.wxzz.elearing.pay.entity.UserTransaction;
import com.wxzz.elearing.pay.entity.UserWithdrawDeposit;
import com.wxzz.elearing.pay.service.IUserWithdrawDepositService;
import com.wxzz.elearning.common.vo.JgPageVo;
import com.wxzz.elearning.common.vo.ReturnVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户提现记录 前端控制器
 * </p>
 *
 * @author
 * @since 2021-04-23
 */
@RestController
@RequestMapping("/user-withdraw-deposit")
@Api(tags = "提现接口(后台)")
public class UserWithdrawDepositController {

    @Autowired
    private IUserWithdrawDepositService userWithdrawDepositService;

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @ApiOperation(value = "发起提现申请(后台)", notes = "发起提现申请(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "sendUserWithdrawDeposit", method = RequestMethod.POST)
    public ReturnVO sendUserWithdrawDeposit(@RequestHeader String token, @RequestBody SendUserWithdrawDepositDto sendUserWithdrawDepositDto) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        return userWithdrawDepositService.sendUserWithdrawDeposit(jsonObject,sendUserWithdrawDepositDto);
    }


    @ApiOperation(value = "提现申请列表(后台)", notes = "提现申请列表(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "listUserWithdrawDeposit", method = RequestMethod.POST)
    public ReturnVO<JgPageVo<List<UserWithdrawDeposit>>> listUserWithdrawDeposit(@RequestBody UserWithdrawDepositDto userWithdrawDepositDto) {
        return userWithdrawDepositService.listUserWithdrawDeposit(userWithdrawDepositDto);
    }

    @ApiOperation(value = "审核提现(后台)", notes = "审核提现(后台)", httpMethod = "POST", tags = "后台")
    @RequestMapping(value = "checkUserWithdrawDeposit", method = RequestMethod.POST)
    public ReturnVO checkUserWithdrawDeposit(@RequestHeader String token,@RequestBody CheckUserWithdrawDepositDto checkUserWithdrawDepositDto) {
        JSONObject jsonObject = JSONObject.parseObject(redisTemplate.opsForValue().get(token));
        return userWithdrawDepositService.checkUserWithdrawDeposit(jsonObject,checkUserWithdrawDepositDto);
    }

}
